package de.stefanocke.roo.wicket.base;

import org.springframework.roo.classpath.PhysicalTypeMetadata;
import org.springframework.roo.classpath.details.annotations.populator.AbstractAnnotationValues;
import org.springframework.roo.model.JavaType;

import de.stefanocke.roo.wicket.ValidationException;

public abstract class AnnotationValuesBase extends AbstractAnnotationValues {

	public AnnotationValuesBase(PhysicalTypeMetadata governorPhysicalTypeMetadata, Class<?> annotationType) {
		super(governorPhysicalTypeMetadata, new JavaType(annotationType.getName()));
		if (!isAnnotationFound()) {
			throw new ValidationException("Trigger annotation " + annotationType + " not found at "
					+ governorPhysicalTypeMetadata.getId());
		}
		// Note: When subclasses initialize the autopopulated fields with
		// default values, this will overwrite the autopopulated values:
		// Thus, we cannot populate here.

	}

	protected void populate() {
		AutoPopulationUtils.populate(this, annotationMetadata);
	}

}